-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify and correct ProbabilitySampler behaviour #111
Simplify and correct ProbabilitySampler behaviour #111
Conversation
apply_to_root_spans: true, | ||
apply_to_remote_parent: true, | ||
apply_to_all_spans: false) | ||
apply_probability_to: :root_spans_and_remote_parent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collection of boolean flags was confusing, interdependent, incorrectly implemented, and didn't capture either the spirit or intent of the OTEP. Since we're in Ruby, we can have Symbols, so this uses a single Symbol argument to distinguish the 3 supported cases.
@@ -26,51 +30,48 @@ def initialize(probability, hints:, ignore_parent:, apply_to_root_spans:, apply_ | |||
# | |||
# Callable interface for probability sampler. See {Samplers}. | |||
def call(trace_id:, span_id:, parent_context:, hint:, links:, name:, kind:, attributes:) | |||
take_hint(hint) || | |||
use_parent_sampling(parent_context) || | |||
use_link_sampling(links) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OTEP talks about links, but the decision table for ProbabilitySampler
doesn't use them.
use_probability_sampling(trace_id) || | ||
NOT_RECORD | ||
end | ||
ignore(links, name, kind, attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to explicitly ignore the parameters the ProbabilitySampler
doesn't use in its decision. It seemed cleaner that just encoding it in a comment.
NOT_RECORD if !@apply_to_root_spans && parent_context.nil? | ||
def sample(hint, trace_id, parent_context) | ||
if parent_context.nil? | ||
hint == HINT_RECORD_AND_PROPAGATE || probably(trace_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if parent_context.nil? | ||
hint == HINT_RECORD_AND_PROPAGATE || probably(trace_id) | ||
else | ||
parent_sampled_flag(parent_context) || hint == HINT_RECORD_AND_PROPAGATE || probably_for_child(parent_context, trace_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -60,12 +60,6 @@ | |||
result.wont_be :sampled? | |||
end | |||
|
|||
it 'respects link sampling' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProbabilitySampler
doesn't respect Link sampling.
@@ -83,35 +77,30 @@ | |||
result.wont_be :sampled? | |||
end | |||
|
|||
it 'does not sample a root span unless apply_to_root_spans' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a supported case for ProbabilitySampler
. The probability applies to "root spans", "root spans and remote parent", or "all spans".
sdk/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb
Outdated
Show resolved
Hide resolved
sdk/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb
Outdated
Show resolved
Hide resolved
sdk/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb
Outdated
Show resolved
Hide resolved
sdk/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb
Outdated
Show resolved
Hide resolved
This is ready for another 👀 |
This simplifies the interface and implementation of the
ProbabilitySampler
, as well as fixing some bugs wrt the OTEP: https://github.com/open-telemetry/oteps/blob/master/text/0006-sampling.mdI'll call out specifics in comments.